package com.you.spring.boot.starter;


import com.baomidou.mybatisplus.generator.AutoGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MybatisPlusGenerateProperties.class)
public class MybatisPlusGenerateAutoConfiguration {

    @Autowired
    private MybatisPlusGenerateProperties generateProperties;

    @Bean
    @ConditionalOnMissingBean
    public AutoGenerator autoGenerator() {
        AutoGenerator autoGenerator = new AutoGenerator();
        autoGenerator.setStrategy(generateProperties.getStrategy());
        autoGenerator.setGlobalConfig(generateProperties.getGlobalConfig());
        autoGenerator.setPackageInfo(generateProperties.getPackageInfo());
        autoGenerator.setDataSource(generateProperties.getDataSource());
        return autoGenerator;
    }


}
